﻿using AbstractBugTracker;
using Jira.JiraSoap;

namespace Jira
{
    public sealed class JiraBugDef : BugDef
    {
        private readonly RemoteIssue m_RemoteIssue;

        internal JiraBugDef(JiraConfig jiraConfig, JiraConnection connection, JiraBugRef cleanBugRef, RemoteIssue remoteIssue)
            : base(cleanBugRef)
        {
            m_RemoteIssue = remoteIssue;

            // create as a bug
            m_RemoteIssue.type = connection.GetIssueTypeId(jiraConfig.BugIssueTypeName);
        }

        internal RemoteIssue RemoteIssue
        {
            get { return m_RemoteIssue; }
        }

        public void CleanAndSetTitle(string value)
        {
            m_RemoteIssue.summary = JiraUtils.Clean(value, false);
        }

        public void CleanAndSetDescription(string value)
        {
            m_RemoteIssue.description = JiraUtils.Clean(value, true);
        }
    }
}
